import { JSEncrypt } from 'jsencrypt'

// publicKey 是 加密公钥

const publicKey = `
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCNauEF15hykPt7BRKUyRis+UylIQ7KA
q1povqAPM2nLjr4ZCCeRN6tT9A1D4HGnEuP25BCj525QtsESiCedHZm3g1V3p1UzHpb50
skoRrr5yWeocZrLecIR71iuKggdl5bbV+Ze6oThk8ED8JM4GGIqhWib9wXrkrjZwwZou+
XGwIDAQAB
-----END PUBLIC KEY-----
`

// 加密
export const rsaEncrypt = (msg) => {
  const jsencrypt = new JSEncrypt()
  jsencrypt.setPublicKey(publicKey)
  const encryptMsg = jsencrypt.encrypt(msg)
  return encryptMsg
}

// 解密私钥
const privateKey = ``

// 解密,暂时没用到
export const rsaDecrypt = (msg) => {
  const decrypt = new JSEncrypt()
  decrypt.setPrivateKey(privateKey)
  const decryptMsg = decrypt.decrypt(msg)
  return decryptMsg
}
